package time

import (
	"testing"
	"time"
)

// 当前时间戳
func Time(data string) int64 {
	if data != "" {
		t, err := time.Parse("2006-01-02 15:04:05", data)
		if err != nil {
			return 0
		} else {
			return t.Unix()
		}
	} else {
		return time.Now().Unix()
	}
}

func TestNewDate(t *testing.T) {
	date := Time("")
	if date < 1 {
		t.Errorf("Time() failed, got: %d", date)
	}
}
